package com.hoshiicloud.mallshop.controller.goodsmanage;

import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.mallshop.param.ProductSpuParam;
import com.hoshiicloud.mallshop.service.goodsmanage.GoodsReleaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 店铺商品商品发布
 * @author linjx on 2019/9/16
 */
@RestController
@RequestMapping("/goods-manage/goods-release")
@Api(value = "商品管理-发布商品", tags = {"商品管理-发布商品"})
public class GoodsReleaseController {
    private final GoodsReleaseService productReleaseService;

    public GoodsReleaseController(GoodsReleaseService productReleaseService) {
        this.productReleaseService = productReleaseService;
    }

    @ApiOperation(value = "商品发布前的数据准备")
    @GetMapping("/publishPreData")
    public Response publishPreData(@RequestParam Long categoryId) {
        Map<String, Object> myMap = new HashMap<>();
        //TokenUsersVO user = UserInfoUtil.getUserInfo(request);
        myMap.put("companyId", 3171776001692663893L);
       // myMap.put("platformId", user.getPlatId());
        myMap.put("storeId", 59);
        return Response.data(productReleaseService.publishPreData(categoryId,myMap));
    }

    @ApiOperation(value = "发布商品")
    @PostMapping("/releaseProduct")
    public Response saveGoods(@RequestBody ProductSpuParam spuParam) {

        //TokenUsersVO user = UserInfoUtil.getUserInfo(rq);
        spuParam.setCompanyId(3171776001692663893L);
        spuParam.setPlatformId(3189609977215975481L);
        spuParam.setStoreId(58L);
        spuParam.setCreateBy("测试的人");
        return Response.data(productReleaseService.saveGoods(spuParam));

    }

}
